
var parentJson = {};
var sendData = {};
parentJson.bakUrl="../../meeting_info/toSelect";//"http://localhost:8081/unite_platform/meeting_info/toSelect";
parentJson.jsType="add";
parentJson.parameter="";
parentJson.showType="";
var calendar = new lCalendar();
var starttimecalendar = new lCalendar();
var endtimecalendar = new lCalendar();
var thenum = 0;
var _config ;
var photoUrl = [];//拍照列表
var thestart;
var theend
var dingdingUserData = [];
var now = getDay(0);
$.ajax({
	url: "../../adminmanager/user/getUserTreeSelect"
	,type:'post'
	,async: false
	,contentType: "application/json; charset=utf-8"
//	,data:JSON.stringify({})
	,dataType:'json'
	,success: function(res){
		dingdingUserData = res.data;
	}
	,error:function(XMLHttpRequest, textStatus, errorThrown) {
		 console.log(XMLHttpRequest);
		 console.log(textStatus);
		 console.log(errorThrown);
	}
	
});
function openMeetinguser(){
	var index = layer.open({
		type: 1,
		maxmin: true,
		title: '选择人员',
		area: ['300px', '600px'],
		content: '<div id="demo1" class="xm-select-demo-alert"></div>',
//			+'<div class="buttonbox" id="saveButton">'
//			+'<div class="submit_button">提交</div>'
//			+'</div>',
		success: function(layero, index){
			//这里因为内容过少, 会被遮挡, 所以简单修改了下样式
			document.getElementById('layui-layer' + index).getElementsByClassName('layui-layer-content')[0].style.overflow = 'unset';
			//渲染多选
			var meetinguserxmSelect = xmSelect.render({
				el: '#demo1',
				autoRow: true,
				filterable: true,
				theme: {
					color: '#669fc7',
				},
				style: {
					marginTop: '2px',
					borderRadius: '6px',
				},
				tree: {
					show: true,
					simple: false,
					showFolderIcon: true,
					showLine: true,
					indent: 20,
					expandedKeys: [ -3 ],
				},
				model: {
					label: {
						type: 'block',
						block: {
							//最大显示数量, 0:不限制
							showCount: 1,
							//是否显示删除图标
							showIcon: true,
						}
					}
				},
				on: function(data){
					//arr:  当前多选已选中的数据
					setxmSelectValueToInput(data.arr,'','meetinguser')
				},
				toolbar: {
					show: true,
					list: ['ALL', 'REVERSE', 'CLEAR']
				},
				filterable: true,
				direction: 'down',
				height: 300,
				data:dingdingUserData
			});
			setTimeout(function(){
				meetinguserxmSelect.opened();
			}, 800);
		}
	});
	layer.full(index);
}

	
	$.ajax({
			url: '../../meeting_info/fillAdd'
			,type:'post'
			,dataType:'json'
			,contentType: "application/json; charset=utf-8"
			,data:JSON.stringify(parentJson)  
			,success: function(res){
				//请求成功后	
				console.log(res);			
				  if(res.status==1000){
					layer.msg(res.msg);
				  }else{
					  //先填充complexselect的下拉框
			
					layui.each(res.data.select,function(inx,val){
						layui.each(val,function(inxSub,valSub){
							  $("select[name='"+inx+"']").append('<option value="'+valSub.value1+'">'+valSub.key1+'</option>');
						  })
					  });
					//form.render('select');
					//form.val('form1',res.data.field);		
					document.getElementById("mno").value=res.data.field.mno;
				  }	
			}
	});

calendar.init({
	'trigger': '#meetingdate',
	'type': 'date',
	'maxDate': '2099-12-31',
	'minDate':  now
});
starttimecalendar.init({
	'trigger': '#starttime',
	'type': 'time',
	'maxDate': '23:59:59',
	'minDate': '10:00:00'
});
endtimecalendar.init({
	'trigger': '#endtime',
	'type': 'time',
	'maxDate': '23:59:59',
	'minDate': '10:00:00'
});
function ICalendarClick(){
	thestart=document.getElementById("starttime").value; 
	theend=document.getElementById("endtime").value;  
//	console.log(thestart);
//	console.log(theend);  
    if(thestart!=''&&theend==''){
	       /* console.log("success");
			    endtimecalendar.init({
				'trigger': '#endtime',
				'type': 'time',
				'maxDate': '20:00:00',
				'minDate': '10:00:00'
				});*/
	}
}	
$(document).ready(function(){
	
	$('#name').text(sessionStorage.getItem("name"));
	$('#addButton').on('click',addform);
	$('#saveButton').on('click',saveInfo);
//	$('#meetinguser').on('click',openMeetinguser);
	
	$('#meetinguser').on('click',function(){
		var index = layer.open({
			type: 2,
			maxmin: true,
			title: '选择人员',
			area: ["300px", "600px"],
			content: '../adminmanager/toUsersTree?valueInput=meetinguserid&nameInput=meetinguser',
			btn: ['确定', '取消'] ,
			yes: function(index, layero){
			    //do something
			    layer.close(index); //如果设定了yes回调，需进行手工关闭
			},
			btn2: function(index, layero){
			    //do something
			    layer.close(index); //如果设定了yes回调，需进行手工关闭
			},
			success: function(layero, index){
			}
		});
		layer.full(index);
	});
	$(document).on('click','input[jsonKey="checkuser"],input[jsonKey="dutyuser"],input[jsonKey="decisionuser"],input[jsonKey="backuser"]',function(){
		var valueInput = $(this).attr('jsonKey')+'id'+$(this).attr('index');
		var nameInput = $(this).attr('jsonKey')+$(this).attr('index');
		var index = layer.open({
			type: 2,
			maxmin: true,
			title: '选择人员',
			area: ["300px", "600px"],
			content: '../adminmanager/toUsersTree?valueInput='+valueInput+'&nameInput='+nameInput,
			btn: ['确定', '取消'] ,
			yes: function(index, layero){
			    //do something
			    layer.close(index); //如果设定了yes回调，需进行手工关闭
			},
			btn2: function(index, layero){
			    //do something
			    layer.close(index); //如果设定了yes回调，需进行手工关闭
			},
			success: function(layero, index){
			}
		});
		layer.full(index);
	});
	$(document).on('click','div[deleteIndex]',function(){
		var obj = this;
		dd.ready(function(){
			dd.device.notification.confirm({
				message: "确认删除此会议事项吗？",
				title: "提示",
				buttonLabels: ['是', '否'],
				onSuccess : function(result) {
					//onSuccess将在点击button之后回调
					/*
		        {
		            buttonIndex: 0 //被点击按钮的索引值，Number类型，从0开始
		        }
					 */
					if(result.buttonIndex == 0){
						$('div[itemDiv="'+$(obj).attr('deleteIndex')+'"]').remove();
					}
				},
				onFail : function(err) {}
			});
		})
	});
});
$('#paizhao').on('click',function(){
	
	openphoto();
});
//数据保存
function saveInfo(){
	
	showloading();
	try {
		var themeetinguserid=document.getElementById("meetinguserid").value;  
		var themeetinguser=document.getElementById("meetinguser").value;  
	//	$('#meetinguserid').val(meetinguserxmSelect.getValue('valueStr'));
	//	$('#meetinguser').val(meetinguserxmSelect.getValue('nameStr'));
		var sendData = {};
		sendData.infoData={};
		var checkFlag = true;
		$('#meetingDiv input[id]').each(function(i,obj){
			if($(obj).parent().find('span').text() == '*' && $(obj).val() == ''){
				alert($(obj).parent().find('h5').text()+"为必填项");
				checkFlag = false;
				return false;
			}else{
				var key = $(obj).attr('id');
				sendData.infoData[key] = $(obj).val();
				key = null;
			}
		});
		console.log("----------------")
		if(checkFlag){
			$('#meetingDiv select[id]').each(function(i,obj){
				if($(obj).parent().find('span').text() == '*' && $(obj).val() == ''){
					alert($(obj).parent().find('h5').text()+"为必填项");
					checkFlag = false;
					return false;
				}else{
					var key = $(obj).attr('id');
					sendData.infoData[key] = $(obj).val();
					key = null;
				}
			});
		}
		sendData.infoData.meetinguserid=themeetinguserid;
		sendData.infoData.meetinguser=themeetinguser;
		var themeetingusernum = themeetinguserid.split(",");
	//	console.log(themeetingusernum.length);
		sendData.infoData.meetingusernum = themeetingusernum.length
		sendData.infoData.noticeday = 1;
		sendData.infoData.noticemode = 7;
		sendData.infoData.img = photoUrl.join(',');
		
		var insertArray = [];
		var updateArray = [];
		if(checkFlag){
			$('div[itemDiv]').each(function(i,obj){
				var insertJson = {};
				$(obj).find('input[jsonKey]').each(function(j,el){
					if($(el).parent().find('span').text() == '*' && $(el).val() == ''){
						alert($(el).parent().find('h5').text()+"为必填项");
						checkFlag = false;
						return false;
					}else{
						var key = $(el).attr('jsonKey');
						insertJson[key] = $(el).val();
						key = null;
					}
				});
				$(obj).find('select[jsonKey]').each(function(j,el){
					if($(el).parent().find('span').text() == '*' && $(el).val() == ''){
						alert($(el).parent().find('h5').text()+"为必填项");
						checkFlag = false;
						return false;
					}else{
						var key = $(el).attr('jsonKey');
						insertJson[key] = $(el).val();
						key = null;
					}
				});
				insertJson.ino = Number(i)+1;
				insertJson.flag = 10;
				insertJson.actionType = 'add';
				insertArray.push(insertJson);
				console.log(insertJson);
			});
		}
		sendData.insertArray = insertArray;
		sendData.updateArray = updateArray;



		console.log(sendData);
		if(checkFlag){
			$.ajax({
				url: '../../meeting_info/add'
				,type:'post'
				,dataType:'json'
				,async: false
				,contentType: "application/json; charset=utf-8"
					,data:JSON.stringify(sendData)  
					,success: function(res){
						if(res.status==1000){
							layer.msg(res.msg);
						}else{
							layer.msg(res.msg,{time:1000},function(){
								history.go(-1);
							});
						}
					}
			});
		}
	} catch (e) {
		console.log(e)
	} finally{
		hideloading();
	}
	

 
	
}	
//添加表单
function addform() {
	var itemDivIndex = $('div[itemDiv]').length;
    $('#f_div').append('<div class="col_box" itemDiv="'+thenum+'">'
				    		+'<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_mar_tb7p">'
							+'<h5 id="wentishuomingTitle" class="black" style="">会议事项'+(itemDivIndex+1)+'</h5>'
							+'<div deleteIndex="'+thenum+'" class="bt_delete bg_orange">删除</div><div class="clearfix"></div>'
						+'</div>'
    					+'		<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe600;</i>&nbsp;会议事项</h5><span class="red">*</span>'
						+'				<input type="text" id="meetingitem'+thenum+'" placeholder="请输入会议事项" jsonKey="meetingitem" autocomplete="off"  name="meetinglocation" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
						+'			</div>'
						+'		</div>'
						+'	 <div>'
						+'			<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe605;</i>&nbsp;决定人</h5><span class="red">*</span>'
						+'				<input type="hidden" id="decisionuserid'+thenum+'" jsonKey="decisionuserid"/>'
						+'				<input type="text" id="decisionuser'+thenum+'" index="'+thenum+'" jsonKey="decisionuser" placeholder="请选择决定人" readonly="readonly" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
//						+'				<div id="decisionuseridTree'+thenum+'" jsonKey="decisionuserid" class="pull-right" style="width: 78%;margin-right: 2%;"></div>'    								                      
						+'			</div>'
						+'		    </div>'
						+'		    </div>'
						+'		<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe609;</i>&nbsp;回复时间</h5><span class="red">*</span>'
						+'				<input type="text" id="replydate'+thenum+'" placeholder="请选择回复时间" jsonKey="replydate" autocomplete="off"   name="meetinglocation" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
						+'			</div>'
						+'		</div>	'
						+'	    <div>'
						+'			<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe696;</i>&nbsp;责任人</h5><span class="red">*</span>'
						+'				<input type="hidden" id="dutyuserid'+thenum+'" jsonKey="dutyuserid"/>'
						+'				<input type="text" id="dutyuser'+thenum+'" index="'+thenum+'" jsonKey="dutyuser" placeholder="请选择责任人" readonly="readonly" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
//						+'				<div id="dutyuseridTree'+thenum+'" class="pull-right" style="width: 78%;margin-right: 2%;"></div>'    								                      
						+'			</div>'
						+'		    </div>'
						+'		    </div>'
						+'	 <div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe63d;</i>&nbsp;需要提供内容</h5><span class="red">*</span>'
						+'				<input type="text" id="commitcontent'+thenum+'" placeholder="请输入提供内容" jsonKey="commitcontent" autocomplete="off"   name="meetinglocation" class="pull-right add_bor_none" style="width: 60%;margin-right: 2%"/>'
						+'			</div>'
						+'		</div>'
						
						+'		<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe6ea;</i>&nbsp;优先级</h5><span class="red">*</span>'
						+'				<select id="emergency'+thenum+'" jsonKey="emergency" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%;">'
						+'				 <option value =""></option>'
  						+'				<option value ="一般">一般</option>'
				     	+'				<option value ="紧急">紧急</option>'
						+'				<option value ="非常紧急">非常紧急</option>'
						+'				</select> ' 
						+'			</div>'
						+'		</div>'
						
						
						+'		<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe69e;</i>&nbsp;是否检视</h5><span class="red">*</span>'
						+'				<select id="ischeck'+thenum+'" jsonKey="ischeck" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%;">'
						+'				 <option value ="0">是</option>'
  						+'				<option value ="1">否</option>'
						+'				</select> ' 
						+'			</div>'
						+'		</div>'
						
						+'			<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe602;</i>&nbsp;检视人</h5><span class="red"></span>'
						+'				<input type="hidden" id="checkuserid'+thenum+'" jsonKey="checkuserid"/>'
						+'				<input type="text" id="checkuser'+thenum+'" index="'+thenum+'" jsonKey="checkuser" placeholder="请选择检视人" readonly="readonly" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
//						+'				<div id="checkuseridTree'+thenum+'" jsonKey="checkuserid" class="pull-right" style="width: 78%;margin-right: 2%;"></div>' 								                      
						+'			</div>'
						+'		    </div>'
						
						+'			<div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe696;</i>&nbsp;反馈人</h5><span class="red"></span>'
						+'				<input type="hidden" id="backuserid'+thenum+'" jsonKey="backuserid"/>'
						+'				<input type="text" id="backuser'+thenum+'" index="'+thenum+'" jsonKey="backuser" placeholder="请选择反馈人" readonly="readonly" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
//						+'				<div id="backuseridTree'+thenum+'" jsonKey="backuserid" class="pull-right" style="width: 78%;margin-right: 2%;"></div>' 								                      
						+'			</div>'
						+'		    </div>'
						
						+'	    <div class="widget-box add_mar_tb7p">'
						+'			<div class="widget-header widget-header-flat widget-header-small add_pad_tb10p add_bor_tbgrey">'
						+'				<h5><i class="iconfont">&#xe61d;</i>&nbsp;奖罚</h5>'
						+'				<input type="text" id="money'+thenum+'"  placeholder="请输入奖罚金额" jsonKey="money" autocomplete="off"   name="meetinglocation" class="pull-right add_bor_none" style="width: 70%;margin-right: 2%"/>'
						+'			</div>'
						+'		</div>'
						+'	</div>');
    //设置回复日期
    var replydatecalendar = new lCalendar();
    replydatecalendar.init({
    	'trigger': '#replydate'+thenum,
    	'type': 'date',
    	'maxDate': '2099-12-31',
    	'minDate': '2010-01-01'
    });
//    setUserXmselect([],thenum);    
    thenum++;
}	
//设置xmselect
function setUserXmselectOne(dataArray,colIndex,col){
	var layerndex = layer.open({
		type: 1,
		maxmin: true,
		title: '选择人员',
		area: ['300px', '600px'],
		content: '<div id="demo1" class="xm-select-demo-alert"></div>',
		success: function(layero, index){
			//这里因为内容过少, 会被遮挡, 所以简单修改了下样式
			document.getElementById('layui-layer' + index).getElementsByClassName('layui-layer-content')[0].style.overflow = 'unset';
			//渲染多选
			var demoSelect = xmSelect.render({
				el: '#demo1',
				autoRow: true,
				filterable: true,
				theme: {
					color: '#669fc7',
				},
				style: {
					marginTop: '2px',
					borderRadius: '6px',
				},
				tree: {
					show: true,
					simple: false,
					showFolderIcon: true,
					showLine: true,
					indent: 20,
					expandedKeys: [ -3 ],
				},
				model: {
					label: {
						type: 'block',
						block: {
							//最大显示数量, 0:不限制
							showCount: 1,
							//是否显示删除图标
							showIcon: true,
						}
					}
				},
				on: function(data){
					//arr:  当前多选已选中的数据
					setxmSelectValueToInput(data.arr,colIndex,col)
				},
				toolbar: {
					show: true,
					list: ['ALL', 'REVERSE', 'CLEAR']
				},
				filterable: true,
				direction: 'down',
				height: 300,
				data:dingdingUserData
			});
			//有数据
			if(dataArray[colIndex] != undefined){
				demoSelect.setValue(dataArray[colIndex][col+'id'].split(','));	
			}
			setTimeout(function(){
				demoSelect.opened();
			}, 800);
		}
	});
	layer.full(index);
	
}
//设置xmselect
function setUserXmselect(dataArray,index){
	var decisionuseridSelect = xmSelect.render({
		el: '#decisionuseridTree'+index,
		autoRow: true,
		name: 'decisionuseridTree',
		style: {
			marginTop: '2px',
			borderRadius: '6px',
		},
//		radio:true,
//		clickClose: true,
		theme: {
			color: '#669fc7',
		},
		direction: 'up',
		toolbar:{
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		filterable: true,
		searchTips:"输入名字进行搜索",
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 1,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},
		on: function(data){
			//arr:  当前多选已选中的数据
			setxmSelectValueToInput(data.arr,index,'decisionuser')
		},
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 300,
		data:dingdingUserData
	});
	//责任人
	var dutyuseridSelect = xmSelect.render({
		el: '#dutyuseridTree'+index,
		autoRow: true,
		name: 'dutyuseridTree',
		style: {
			marginTop: '2px',
			borderRadius: '6px',
		},
//		radio:true,
//		clickClose: true,
		theme: {
			color: '#669fc7',
		},
		direction: 'up',
		toolbar:{
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		filterable: true,
		searchTips:"输入名字进行搜索",
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 1,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},
		on: function(data){
			//arr:  当前多选已选中的数据
			setxmSelectValueToInput(data.arr,index,'dutyuser')
		},
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 300,
		data:dingdingUserData
	});
	//检视人
	var checkuseridSelect = xmSelect.render({
		el: '#checkuseridTree'+index,
		autoRow: true,
		name: 'checkuseridTree',
		style: {
			marginTop: '2px',
			borderRadius: '6px',
		},
//		radio:true,
//		clickClose: true,
		theme: {
			color: '#669fc7',
		},
		direction: 'up',
		toolbar:{
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		filterable: true,
		searchTips:"输入名字进行搜索",
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 1,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},
		on: function(data){
			//arr:  当前多选已选中的数据
			setxmSelectValueToInput(data.arr,index,'checkuser')
		},
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 300,
		data:dingdingUserData
	});
	//反馈人
	var backuseridSelect = xmSelect.render({
		el: '#backuseridTree'+index,
		autoRow: true,
		name: 'backuseridTree',
		style: {
			marginTop: '2px',
			borderRadius: '6px',
		},
		theme: {
			color: '#669fc7',
		},
		direction: 'up',
		toolbar:{
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		filterable: true,
		searchTips:"输入名字进行搜索",
		model: {
			label: {
				type: 'block',
				block: {
					showCount: 1,
					showIcon: true,
				}
			}
		},
		on: function(data){
			//arr:  当前多选已选中的数据
			setxmSelectValueToInput(data.arr,index,'backuser')
		},
		tree: {
			show: true,
			showFolderIcon: true,
			showLine: true,
			indent: 20,
			expandedKeys: [ -1 ],
		},
		height: 300,
		data:dingdingUserData
	});
	//有数据
	if(dataArray[index] != undefined){
		decisionuseridSelect.setValue(dataArray[index].decisionuserid.split(','));	
		dutyuseridSelect.setValue(dataArray[index].dutyuserid.split(','));
		checkuseridSelect.setValue(dataArray[index].checkuserid.split(','));
		backuseridSelect.setValue(dataArray[index].checkuserid.split(','));
	}
}
//将xmselect值放到input中
function setxmSelectValueToInput(dataArray,index,col){
	var valueArray = [];
	var nameArray = [];
	for (var i = 0; i < dataArray.length; i++) {
		valueArray.push(dataArray[i].value);
		nameArray.push(dataArray[i].name);
	}
	parent.$('#'+col+'id'+index).val(valueArray.join(','));
	parent.$('#'+col+index).val(nameArray.join(','));
}
//打开钉钉拍照
function openphoto(){
	if(_config == undefined){
		$.ajax({
			type : "post",
			data:JSON.stringify({"pageUrl":location.href.replace(/\\&/g,'%26')}),
			contentType: "application/json; charset=utf-8",
			async: false,
			url : "../../dingding/getconfig",
			dataType : "json",
			success : function(suc) {
//				console.log(suc);
				_config = suc.config;
			}
		}); 
		dd.config({
			agentId : _config.agentid,
			corpId : _config.corpId,
			timeStamp : _config.timeStamp,
			nonceStr : _config.nonceStr,
			signature : _config.signature,
			jsApiList : [ 'runtime.info','biz.util.uploadImage' ]
		});
	}
	dd.ready(function(){
		dd.biz.util.uploadImage({
		    compression: false,//(是否压缩，默认为true)
		    quality: 100, // 图片压缩质量, 
		    resize: 100, // 图片缩放率
		    stickers: {   // 水印信息
		        time: getNowFormatDateTime(),
		        username: sessionStorage.getItem("name")
		    },
		    onSuccess : function(result) {
			photoUrl.push(result[0]);
			$('#paizhapoUrl .clearfix').remove()
			$('#paizhapoUrl').append('<div class="wig_img">'
					+'<div class="img_box">'
					+'<img alt="100x100" src="'+result[0]+'" onclick="showAllPic(\''+result[0]+'\')"/>'
					+'<img class="close_b" src="../../genius/style/mobile_page/assets/images/close.png" onclick="deletePhoto(this)">'
					+'</div>'
					+'</div>');
			$('#paizhapoUrl').append('<div class="clearfix"></div>');
		    },
		    onFail : function(err) {}
		});
	});
}	
//删除图片
function deletePhoto(obj){
	dd.device.notification.confirm({
	    message: "删除图片吗",
	    title: "提示",
	    buttonLabels: ['是', '否'],
	    onSuccess : function(result) {
	    	if(result.buttonIndex == '0'){
	    		var index = $(obj).parent().parent().index();
	    		$(obj).parent().parent().remove();
	    		photoUrl.splice(index,1);
	    	}
	        
	    },
	    onFail : function(err) {}
	});
	 
}
//预览图片
function showAllPic(imgOne){
	dd.biz.util.previewImage({
		urls: photoUrl,//图片地址列表
		current: imgOne,//当前显示的图片链接
		onSuccess : function(result) {
			/**/
		},
		onFail : function(err) {}
	})
}
